package org.forum.service.impl;

import java.util.List;

import org.forum.dao.MainTopicDao;
import org.forum.dao.ReplyDao;
import org.forum.domain.Reply;
import org.forum.service.MainTopicService;
import org.forum.utils.JsonUtil;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class MainTopicServiceImpl implements MainTopicService{
	
	Logger logger = LoggerFactory.getLogger(MainTopicServiceImpl.class);
	
	private MainTopicDao mainTopicDao;

	public void setMainTopicDao(MainTopicDao mainTopicDao) {
		this.mainTopicDao = mainTopicDao;
	}

	private ReplyDao replyDao;

	public void setReplyDao(ReplyDao replyDao) {
		this.replyDao = replyDao;
	}

	private JsonUtil jsonUtil;

	public void setJsonUtil(JsonUtil jsonUtil) {
		this.jsonUtil = jsonUtil;
	}

	@Override
	public void getRepliesByMainTopicId(int mainTopicId) {
		List<Reply> replies = replyDao.getRepliesByMainTopicId(mainTopicId);
		JSONObject jsonObject = new JSONObject();
		jsonObject.put(Integer.toString(mainTopicId), replies);
		jsonUtil.outToJsonString(jsonObject.toString());
	}

	
	
}
